package com.hao.tool.web.module.fileInfo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hao.tool.web.module.fileInfo.entity.TemplateInfo;
import com.hao.tool.web.module.fileInfo.mapper.TemplateMapper;
import com.hao.tool.web.module.fileInfo.service.TemplateService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * description
 *
 * @author RuiHaoZ on GZ.cmhk
 * @date 2019-11-23 14:24
 */
@Service
public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, TemplateInfo> implements TemplateService {
    @Override
    public List<TemplateInfo> findBySourceName(String fileName) {
        QueryWrapper<TemplateInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("SOURCE_NAME", fileName);
        return list(queryWrapper);
    }

    @Override
    public boolean fileNameIsExist(String fileName) {
        List<TemplateInfo> list = this.findBySourceName(fileName);
        if (list == null || list.isEmpty()) {
            return false;
        }
        return true;
    }
}
